package cn.livingCloud.entity.user;

import org.apache.commons.lang.StringUtils;

public enum Privilege {
    //    用户管理权限
    USER_MANAGER("用户管理:显示界面权限", "USER_MANAGER", "*"),
    USER_LIST("用户管理:用户列表", "USER_LIST", "*"),
    USER_ACCOUNT("用户管理:账号列表", "USER_ACCOUNT", "*"),
    //    微信管理权限
    WECHAT("微信管理:显示界面权限", "WECHAT", "*"),
    MEMBER_LIST("微信管理:粉丝列表", "MEMBER_LIST", "*"),
    REPLY_RULE_LIST("微信管理:微信回复规则", "REPLY_RULE_LIST", "*"),
    BUTTON_LIST("微信管理:自定义菜单", "BUTTON_LIST", "*"),
    //文章列表权限
    ARTICLE_LIST("文章列表", "ARTICLE_LIST", "*"),
    //图片管理
    IMAGE_LIST("图片", "IMAGE_LIST", "*"),
    //常用回复设置
    REPLY_SET_LIST("常用回复设置", "REPLY_SET_LIST", "*"),
    //组织结构管理
    ORGANIZATION_MANAGER("组织结构管理", "ORGANIZATION_MANAGER", "*", true),
    ORGANIZATION_DEPT_LIST("组织结构管理:部门列表", "ORGANIZATION_DEPT_LIST", "*", true),
    ORGANIZATION_ACCOUNT_LIST("组织结构管理:账号列表", "ORGANIZATION_ACCOUNT_LIST", "*", true),
    ORGANIZATION_EMPLOYEE_LIST("组织结构管理:员工管理", "ORGANIZATION_EMPLOYEE_LIST", "*", true),
    //案件管理
    CMC("案件管理", "CMC", "*", true),
    CMC_CATEGORY_LIST("案件管理:案件分类", "CMC_CATEGORY_LIST", "*", true),
    CMC_CASE_UNFINISHED("案件管理:未完成案件列表", "CMC_CASE_UNFINISHED", "*", true),
    CMC_CASE_REVIEWED("案件管理:待审核案件列表", "CMC_CASE_REVIEWED", "*"),
    CMC_CASE_FINISH("案件管理:已完成案件列表", "CMC_CASE_FINISH", "*", true),
    //    CMC_CASE_STUBBORN("案件管理:持续未完成案件列表", "CMC_CASE_STUBBORN", "*", true),
    CMC_CASE_LOCK("案件管理:已锁定案件列表", "CMC_CASE_LOCK", "*", true),
    //系统设置
    SETTING("系统设置", "SETTING", "*"),
    //案件处理
    CMC_REPORT("上报案件", "CMC_REPORT", "*", true),
    CMC_CANCEL("作废案件", "CMC_CANCEL", "*", true),
    CMC_ASSIGNMENT("分派案件", "CMC_ASSIGNMENT", "*", true),
    CMC_FINISH("完成案件", "CMC_FINISH", "*", true),
    CMC_CATEGORY("案件类别修改", "CMC_CATEGORY", "*"),
    //报表管理
    REPORT_FORM("报表管理", "REPORT_FORM", "*", true),
    REPORT_FORM_PUSH_GROUP("报表管理:推送分组", "REPORT_FORM_PUSH_GROUP", "*"),
    REPORT_FORM_REPORT_RULE("报表管理:报表规则", "REPORT_FORM_REPORT_RULE", "*"),
    SELF_BINDING("自助绑定", "SELF_BINDING", "*");
    private static final String SPLIT = ":";
    private String label;
    private String code;
    private String operate;
    private boolean employee = false;

    Privilege(String label, String code) {
        this.label = label;
        this.code = code;
    }

    Privilege(String label, String code, String operate) {
        this.label = label;
        this.code = code;
        this.operate = operate;
    }

    Privilege(String label, String code, String operate, boolean employee) {
        this.code = code;
        this.employee = employee;
        this.label = label;
        this.operate = operate;
    }

    public String getCode() {
        return code;
    }

    public Privilege setCode(String code) {
        this.code = code;
        return this;
    }

    public boolean isEmployee() {
        return employee;
    }

    public Privilege setEmployee(boolean employee) {
        this.employee = employee;
        return this;
    }

    public String getLabel() {
        return label;
    }

    public Privilege setLabel(String label) {
        this.label = label;
        return this;
    }

    public String getOperate() {
        return operate;
    }

    public Privilege setOperate(String operate) {
        this.operate = operate;
        return this;
    }

    public String getPermissionAsString() {
        if (StringUtils.isNotEmpty(operate)) {
            return code + SPLIT + operate;
        }
        return code;
    }
}
